/**
 * 公共接口
 */

import Axios from '@/utils/request';
import { DictVO } from '../vo';

/**
 * 表格布局接口
 * @param {string} tableName 表格名
 */
export function getTableLayout(tableName: string): Promise<any> {
    return Axios.get('/tableLayout/query/' + tableName);
}

/**
 * 表格布局接口
 * @param {string} tableName 表格名
 */
export function getTableLayout2(tableName: string): Promise<any> {
    return new Promise((resolve, reject) => {
        Axios.get('/tableLayout/query/' + tableName)
            .then((res: any) => {
                resolve(JSON.parse(res || 'false'));
            })
            .catch(error => {
                reject(error);
            });
    });
}

/**
 * 更新表格布局
 * @param tableName
 */
export function updateTableLayout(data: any): Promise<any> {
    return Axios.post('/tableLayout/insert', data)
}

/**
* 模糊查询发行人下拉框
* @param type 准确搜索 0-否 1-是
*/
export const getIssueSelect = (val: string, type?: string): Promise<DictVO[]> => {
    const data = { dictKey: val, dictKeyName: val, precision: type }
    return Axios.post('/dict/issue/select', data);
}
